package com.liwenfeng.diancanspringboot.config;

import com.liwenfeng.diancanspringboot.common.properties.CosProperties;
import com.liwenfeng.diancanspringboot.common.utils.CosUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class CosConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public CosUtil cosUtil(CosProperties cosProperties) {
        return new CosUtil(cosProperties.getDirectory(), cosProperties.getBaseUrl(), cosProperties.getSecretId(), cosProperties.getSecretKey(), cosProperties.getBucket(), cosProperties.getRegion());
    }
}
